package com.example.check.validator;

import com.example.check.Sex;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 性别约束逻辑判断
 * 继承ConstraintValidator key填对应需要校验的注解
 * 重写isValid作为校验逻辑
 * @author mo_chou_555
 */
public class SexConstraintValidator implements ConstraintValidator<Sex, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return ("男".equals(value) || "女".equals(value));
    }
}